using UnityEngine;
using System.Collections;

public class frog : MonoBehaviour {
	
	public float timer=0f;
	public int mode=0;
	public float str=5f;
	public GameObject puff;
	
	void Update () {
		
		timer+=Time.deltaTime;
		
		if(mode==0)
		{
			if(timer>1f)
			{
				timer=0f;
				mode=1;
				rigidbody2D.velocity=new Vector3(-str,str*2,0f);

				GameObject clone;
				clone=Instantiate(puff,transform.position,transform.rotation) as GameObject;
				Destroy(clone,3f);
			}
		}
		
		if(rigidbody2D.velocity.magnitude<0.01f && mode==1)
		{
			timer=0f;
			mode=0;
		}
	}
	/*
	void OnCollisionEnter(Collision c)
	{
		if(c.gameObject.name=="ground" || rigidbody2D.IsSleeping())
		{
			if(mode==1)
			{
				timer=0f;
				mode=0;
			}
		}
	}
	*/
}
